<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>库存变动</title>
		<link rel="stylesheet" href="../../lib/layui-v2.6.3/css/layui.css" media="all">
		<link rel="stylesheet" href="../../css/public.css" media="all">
		<style>
			.layui-tab-card>.layui-tab-title .layui-this{
				background-color: #1E9FFF;
				color: white;
				border: none;
			}
			
			.layui-tab-content{
				padding: 0;
			}
			
			.layui-tab,.layui-table, .layui-table-view{
				margin: 0px;
			}
			
			.layui-tab-title li{
				border: 1px solid #EBEBEB;
				border-left: none;
				border-top: none;
				border-bottom: none;
				background-color: #FFFFFF;
			}

			#treeControl{
				position: absolute;
				width: 276px;
				height: 230px;
				border: 1px solid lightgray;
				background: #FFFFFF;
				z-index: 999;
				display: none;
			}

			#treeContext+div{
				padding: 5px;
				text-align: center;
			}

		</style>
	</head>
	<body>
		<!-- 功能切换栏 -->
		<div id="insertCommodityInfo">
			<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
				<ul class="layui-tab-title">
					<li class="layui-this">库存变动情况</li>
					<li>商品变动情况</li>
					<li>商品月变动</li>
				</ul>
				<div class="layui-tab-content">
					<!-- 库存变动情况 -->
					<div class="layui-tab-item layui-show">
						<!-- 搜索功能栏 -->
						<form class="layui-form" id="searchinventorydesc">
							<div class="layui-panel" style="padding-top: 20px;margin: 5px 0;">
								<div class="layui-form-item layui-font-black ">
									<div class="layui-inline">
										<label class="layui-form-label">仓库：</label>
										<div class="layui-input-inline">
											<select name="inveDescDepot" id="inveDescDepot" lay-filter="inveDescDepot">
												<option value="">所有仓库</option>
											</select>
										</div>
									</div>
									<div class="layui-inline">
										<input type="hidden" name="inveDescType">
										<label class="layui-form-label">商品类别：</label>
										<div class="layui-input-inline">
											<input type="text" class="layui-input" id="comTypeTree"
												   value="所有类别" readonly style="cursor: pointer"/>
											<div id="treeControl">
												<div id="treeContext" style="height: 186px ;overflow: auto"></div>
												<div>
													<button type="button" class="layui-btn layui-btn-sm">清空</button>
													<button type="button" class="layui-btn layui-btn-sm">退出</button>
												</div>
											</div>
										</div>
									</div>
									<div class="layui-inline">
										<label class="layui-form-label" style="width: 150px;">输入商品相关信息：</label>
										<div class="layui-input-inline">
											<input type="text" placeholder="请输入商品编号或名称" name="inveDescName" class="layui-input">
										</div>
									</div>
									<!-- 搜索按钮 -->
									<div class="layui-inline">
										<button type="submit" class="layui-btn layui-btn-primary" lay-submit lay-filter="data-searchtotaldesc-btn">
											<i class="layui-icon">&#xe615;</i> 查 询
										</button>
									</div>
									<!-- 重置按钮 -->
									<div class="layui-inline">
										<button id="btnReset1" class="layui-btn icon-btn">
											<i class="layui-icon">&#xe669;</i> 重 置 
										</button>
									</div>
								</div>
							</div>
						</form>
						
						<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
							<ul class="layui-tab-title">
								<li class="layui-this">库存商品汇总表</li>
								<li>库存商品明细</li>
							</ul>
							<div class="layui-tab-content">
								<div class="layui-tab-item layui-show">
									<!-- 库存商品汇总表 -->
									<table class="layui-hide" id="comSummaryTable" lay-filter="comSummaryTable"></table>

									<fieldset class="table-search-fieldset" style="margin-top: 20px;border: 1px solid lightgray;">
										<legend style="font-size: 17px;color: dimgray;">该商品批次信息（仓库名称：<span id="inveDepotName">所有仓库</span>）
										</legend>
										<!-- 商品批次信息 -->
										<table class="layui-hide" id="proBatchInfo" lay-filter="proBatchInfo"></table>
									</fieldset>
									
								</div>
								<div class="layui-tab-item">
									<!-- 库存商品明细 -->
									<table class="layui-hide" id="comDetailTable" lay-filter="comDetailTable"></table>
								</div>
							</div>
						</div>
					</div>
					
					<!-- 商品变动情况 -->
					<div class="layui-tab-item">
						<!-- 搜索功能栏 -->
						<form class="layui-form" id="searchComChangeInfo" >
							<div class="layui-panel" style="padding-top: 20px;margin: 5px 0;">
								<div class="layui-form-item layui-font-black ">
									<div class="layui-inline">
										<label class="layui-form-label">统计时间：</label>
										<div class="layui-input-inline">
											<input type="text" name="startChangeDate" id="startChangeDate" autocomplete="off" class="layui-input">
										</div>
										<div style="display: inline-block;float: left;padding: 10px 13px 0 0;">至</div>
										<div class="layui-input-inline">
											<input type="text" name="stopChangeDate" id="stopChangeDate" autocomplete="off" class="layui-input">
										</div>
									</div>
									<div class="layui-inline">
										<label class="layui-form-label" style="width: 150px;">商品名称或编号：</label>
										<div class="layui-input-inline">
											<input type="text" name="inveDescName" placeholder="请输入商品编号或名称" class="layui-input">
										</div>
									</div>
									<!-- 搜索按钮 -->
									<div class="layui-inline">
										<button type="button" class="layui-btn layui-btn-primary" lay-submit lay-filter="data-searchComChange-btn">
											<i class="layui-icon">&#xe615;</i> 查 询
										</button>
									</div>
									<!-- 重置按钮 -->
									<div class="layui-inline">
										<button id="btnReset2" class="layui-btn icon-btn">
											<i class="layui-icon">&#xe669;</i> 重 置 
										</button>
									</div>
								</div>
							</div>
						</form>
						
						<!-- 商品变动情况表 -->
						<table class="layui-hide" id="comChangeTable" lay-filter="comChangeTable"></table>
					</div>
					
					<!-- 商品月变动 -->
					<div class="layui-tab-item">
						<!-- 搜索功能栏 -->
						<form class="layui-form" id="searchWareMonthChangeInfo">
							<div class="layui-panel" style="padding-top: 20px;margin: 5px 0;">
								<div class="layui-form-item layui-font-black ">
									<div class="layui-inline">
										<label class="layui-form-label">统计时间：</label>
										<div class="layui-input-inline">
											<input type="text" name="statisticalTime" id="statisticalTime" autocomplete="off" class="layui-input">
										</div>
									</div>
									<div class="layui-inline">
										<label class="layui-form-label" style="width: 150px;">输入商品资料查询：</label>
										<div class="layui-input-inline">
											<input type="text" placeholder="请输入商品编号或名称" name="inveDescName" class="layui-input">
										</div>
									</div>
									<!-- 搜索按钮 -->
									<div class="layui-inline">
										<button type="button" class="layui-btn layui-btn-primary" lay-submit lay-filter="data-searchWareMonthChange-btn">
											<i class="layui-icon">&#xe615;</i> 查 询
										</button>
									</div>
									<!-- 重置按钮 -->
									<div class="layui-inline">
										<button id="btnReset3" class="layui-btn icon-btn">
											<i class="layui-icon">&#xe669;</i> 重 置 
										</button>
									</div>
								</div>
							</div>
						</form>
						
						<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
							<ul class="layui-tab-title">
								<li class="layui-this">变动汇总</li>
								<li>变动明细</li>
							</ul>
							<div class="layui-tab-content">
								<div class="layui-tab-item layui-show">
									<!-- 变动汇总表 -->
									<table class="layui-hide" id="changeCollectTable" lay-filter="changeCollectTable"></table>
								</div>
								<div class="layui-tab-item">
									<!-- 变动明细表 -->
									<table class="layui-hide" id="changeDetailTable" lay-filter="changeDetailTable"></table>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<input type="hidden" id="totalCount"/>

		<script src="../../lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
		<script src="../../js/lay-config.js?v=1.0.4" charset="utf-8"></script>
		<script>
			layui.use(['form', 'table', 'layer', 'laydate','tableSelect','tree'], function() {
				var $ = layui.jquery,
					form = layui.form,
					table = layui.table,
					layer = layui.layer,
					tableSelect=layui.tableSelect,
					laydate = layui.laydate,
                	tree = layui.tree;

                /* ---------- 是否补零操作 ---------- */
                function isAddZero(num){
                    return num<10 ? "0"+num : num;
                }

                /* ---------- 日期格式化的函数 ---------- */
                function getFormatDate(obj) {
                    var date = new Date(obj);

                    var year = isAddZero(date.getFullYear());
                    var month = isAddZero(date.getMonth()+1);
                    var day = isAddZero(date.getDate());

                    return year + "-" + month + "-" + day;
                }

                //动态给商品变动情况的统计时间赋值
                var earliestDate;
                $.ajax({
                    url: '/searchEarliestDate',
                    dataType: 'json',
                    type: 'get',
                    success: function (data) {
                        earliestDate = getFormatDate(data);
                        //日历控件
                        laydate.render({
                            elem: "#startChangeDate",
                            value: earliestDate
                        });
                    }
                });

				//日历控件
				laydate.render({
					elem: "#stopChangeDate",
                    value: new Date()
				});

				laydate.render({
					elem: "#statisticalTime",
                    format: 'yyyy-MM',
                    type: 'month',
                    value: new Date()
				});

                //将仓库信息赋值给下拉框
                $.ajax({
                    url: '/searchDepotInfoProcess',
                    dataType: 'json',
                    type: 'get',
                    success: function (data) {
                        $.each(data, function (index, item) {
                            // 下拉菜单里添加元素
                            $('#inveDescDepot').append(new Option(item.depotName,item.depotId));
                        });
                        //重新渲染 固定写法
                        layui.form.render("select");
                    }
                });

                //获取下拉框选中的仓库编号
				var inventoryDesc = $('#searchinventorydesc').serialize();
                var inveDescDepot = "所有仓库";
                form.on('select(inveDescDepot)',function(data){
                    inventoryDesc = $('#searchinventorydesc').serialize();
                    inveDescDepot = data.elem[data.elem.selectedIndex].text;
                    //重载库存汇总表
                    table.reload('comSummaryTable',{
                        url: '/searchInventoryCollectInfo?'+inventoryDesc
                    },'data');
					//调用根据商品编号显示不同的批次信息方法
                    clickLoadProBatchNumData();
                    $('#inveDepotName').html(inveDescDepot);
                    //重载商品明细表
                    table.reload('comDetailTable',{
                        url: '/searchInventoryDescProcess?'+inventoryDesc
                    },'data');
                });

                /*
                * 所选商品列表添加样式
                * 根据商品编号显示不同的批次信息
                */
                function clickLoadProBatchNumData() {
                    var ProBatchNumData = "";
                    table.on('row(comSummaryTable)', function(obj){
                        obj.tr.addClass('layui-bg-green').siblings().removeClass('layui-bg-green');
                        var ProBatchNumData = obj.data;
                        table.reload('proBatchInfo',{
                            url: '/searchProBatchNumInfo/'+ProBatchNumData.proId+'?inveDescDepot='+ $('#inveDescDepot').val() +''
                        },'data');
                    });
                    table.reload('proBatchInfo',{
                        url: '/searchProBatchNumInfo/'+ProBatchNumData.proId+'?inveDescDepot='+ $('#inveDescDepot').val() +''
                    },'data');
                };

                //调用根据商品编号显示不同的批次信息方法
                clickLoadProBatchNumData();

				// 监听库存变动查询操作
				form.on('submit(data-searchtotaldesc-btn)',function (data) {
					var inventoryDesc = $('#searchinventorydesc').serialize();

					//执行查询重载
					table.reload('comDetailTable',{
					    url:'/searchInventoryDescProcess?'+inventoryDesc,
					    page:{curr:1}
					},'data');

                    table.reload('comSummaryTable',{
                        url:'/searchInventoryCollectInfo?'+inventoryDesc,
                        page:{curr:1}
                    },'data');
                    clickLoadProBatchNumData();
					return false;
                });

				//库存明细表弹窗
                function openInventDescTable() {
                    layer.open({
                        type: 2,
                        title: '<h3 style="color: #1E9FFF;font-weight: bold;">库存明细表<h3>',
                        shade: 0.2,
                        maxmin:true,
                        shadeClose: true,
                        area: ['80%', '95%'],
                        scrollbar: false,
                        content:'inventsearchdetail.html'
                    });
                };

                //定义全局变量
                window.comData = "";
                //标识双击库存汇总表还是双击商品变动表
                window.isInventDescTable = false;
				//双击汇总行查看库存明细表
                table.on('rowDouble(comSummaryTable)', function(obj){
                    var comDescData = obj.data;
                    //JSON格式对象 --> String对象
                    comData =JSON.stringify(comDescData);
                    isInventDescTable = true;
                    //调用库存明细表弹窗
                    openInventDescTable();
                });
                table.on('rowDouble(comChangeTable)', function(obj){
                    obj.tr.addClass('layui-bg-green').siblings().removeClass('layui-bg-green');
                    var comDescData = obj.data;
                    comData =JSON.stringify(comDescData);
                    isInventDescTable = false;
                    //调用库存明细表弹窗
                    openInventDescTable();
                });

                // 监听商品变动查询操作
                form.on('submit(data-searchComChange-btn)',function (data) {
                    var comChange = $('#searchComChangeInfo').serialize();

                    //执行查询重载
                    table.reload('comChangeTable',{
                        url:'/searchInventoryChange?'+ comChange,
                        page:{curr:1}
                    },'data');
                });

                //监听商品月变动查询操作
                form.on('submit(data-searchWareMonthChange-btn)',function (data) {
                    var wareChange = $('#searchWareMonthChangeInfo').serialize();

                    //执行查询重载
                    table.reload('changeCollectTable',{
                        url:'/searchWareMonthChange?'+wareChange,
                        page:{curr:1}
                    },'data');

                    //执行查询重载
                    table.reload('changeDetailTable',{
                        url:'/searchWareMonthChangeDesc?'+wareChange,
                        page:{curr:1}
                    },'data');
                });

                //获取序列化表单信息
                var comChange = $('#searchComChangeInfo').serialize();

                //获取序列化表单信息
                var wareChange = $('#searchWareMonthChangeInfo').serialize();

				//库存商品汇总表
				table.render({
					 elem: '#comSummaryTable',
					 url: '/searchInventoryCollectInfo',
					 toolbar: '#toolbarDemo',
					 defaultToolbar: ['filter', 'exports', 'print', {
						 title: '提示',
						 layEvent: 'LAYTABLE_TIPS',
						 icon: 'layui-icon-tips'
					 }],
					 totalRow: true,
					 cols: [[
						 {field: 'proId', width: 120, title: '商品编号', sort: true, fixed:'left',align: "center", totalRowText: '合计:'},
						 {field: 'inveDescName', width: 210, title: '商品名称',align: "center"},
						 {field: 'inveDescInventoryNum', width: 90, title: '库存量', sort: true, align: "center", totalRow: true},
						 {field: 'inveTotalSaleNum', width: 105, title: '销售总数', sort: true, align: "center", totalRow: true},
						 {field: 'inveDescPrice', title: '成本均价', width: 105, sort: true, align: "center",templet:function (data) {
                                 var price = parseFloat(data.inveDescPrice).toFixed(2); //设置小数点后个数
                                 return price;
						 }},
						 {field: 'inveTotalPrice', width: 105, title: '库存总值', sort: true, align: "center", totalRow: true,templet:function (data) {
                                 var price = parseFloat(data.inveTotalPrice).toFixed(2); //设置小数点后个数
                                 return price;
						 }},
						 {field: 'invePresetPrice', width: 105, title: '预设售价', sort: true,align: "center"},
						 {field: 'inveSaleTotalPrice', width: 105, title: '售价总值', sort: true, align: "center", totalRow: true},
						 {field: 'inveDescUnit', width: 80, title: '单位', align: "center"},
						 {field: 'inveDescSize', width: 120, title: '产品规格', align: "center"},
						 {field: 'inveDescPostil', width: 110, title: '批准文号', align: "center"},
						 {field: 'inveDescManufacturer', width: 200, title: '生产厂商', align: "center"},
						 {field: 'inveDescComment', width: 120, title: '备注', align: "center"}
					 ]],
					 done: function(res){
						 $('#totalCount').val(res.count);
                         $('.layui-table-view[lay-id="comSummaryTable"]')
                             .children('.layui-table-box')
                             .children('.layui-table-body')
                             .find('table tbody tr[data-index="0"]').click();
					 },
					 limits: [10, 15, 20, 25, 50, 100],
					 limit: 10,
					 page: true
				});
				
				//商品批次信息表
				table.render({
					elem: '#proBatchInfo',
                    data:[],
                    totalRow: true,
                    cols: [[
                        {field: 'proId', title: '商品编号', sort: true, align: "center"},
                        {field: 'inveDescName', title: '商品名称', minWidth: 325,align: "center"},
                        {field: 'inveDescBatchNum', title: '产品批号', align: "center"},
                        {field: 'inveDescValidityDate', title: '有效期至', sort: true, align: "center",
                            templet:"<div>{{layui.util.toDateString(d.inveDescValidityDate, 'yyyy-MM-dd')}}</div>"},
						{field: 'purStoDate', title: '进货日期', sort: true, align: "center",
                            templet:"<div>{{layui.util.toDateString(d.purStoDate, 'yyyy-MM-dd')}}</div>"},
                        {field: 'inveDescInventoryNum', title: '库存数量', sort: true, totalRow: true, align: "center"}
                    ]]
				});
				
				//库存商品明细表
				table.render({
					 elem: '#comDetailTable',
					 url: '/searchInventoryDescProcess',
					 toolbar: '#toolbarDemo',
					 defaultToolbar: ['filter', 'exports', 'print', {
						 title: '提示',
						 layEvent: 'LAYTABLE_TIPS',
						 icon: 'layui-icon-tips'
					 }],
					 totalRow: true,
					 cols: [[
						 {field: 'proId', width: 110, title: '商品编号', sort: true, totalRowText: '合计:', align: "center"},
						 {field: 'inveDescName', width: 210, title: '商品名称', align: "center"},
						 {field: 'inveDescType', width: 110, title: '商品类别', align: "center"},
						 {field: 'inveDescUnit', width: 60, title: '单位', align: "center"},
						 {field: 'inveDescSize', title: '产品规格', width: 100, align: "center"},
						 {field: 'inveDescPostil', width: 90, title: '批准文号', align: "center"},
						 {field: 'inveDescBatchNum', width: 120, title: '批号', align: "center"},
                         {field: 'inveDescDepot', width: 105, title: '所在仓库', align: "center"},
                         {field: 'inveDescPrice', width: 90, title: '成本价', sort: true, align: "center",templet:function (data) {
                                 var price = parseFloat(data.inveDescPrice).toFixed(2); //设置小数点后个数
                                 return price;
                         }},
                         {field: 'inveDescInventoryNum', width: 105, title: '库存数量', sort: true, totalRow: true, align: "center"},
                         {field: 'inveTotalPrice', width: 110, title: '库存总值', sort: true, totalRow: true, align: "center"},
                         {field: 'inveDescManufacturer', width: 200, title: '生产厂商', sort: true, align: "center"},
						 {field: 'inveDescStartDate', width: 110, title: '生产日期', sort: true, align: "center",
                             templet:"<div>{{layui.util.toDateString(d.inveDescStartDate, 'yyyy-MM-dd')}}</div>"},
						 {field: 'inveDescValidityDate', width: 110, title: '有效期', sort: true, align: "center",
                             templet:"<div>{{layui.util.toDateString(d.inveDescValidityDate, 'yyyy-MM-dd')}}</div>"},
						 {field: 'inveDescComment', width: 100, title: '备注', align: "center"}
					 ]],
					 limits: [10, 15, 20, 25, 50, 100],
					 limit: 10,
					 page: true
				});
				
				//商品变动情况表
				table.render({
					 elem: '#comChangeTable',
					 url: '/searchInventoryChange?'+comChange,
					 toolbar: '#toolbarDemo',
					 defaultToolbar: ['filter', 'exports', 'print', {
						 title: '提示',
						 layEvent: 'LAYTABLE_TIPS',
						 icon: 'layui-icon-tips'
					 }],
                     totalRow: true,
					 cols: [[
						 {width: 120, title: '商品信息',align:'center', colspan: 4},
						 {width: 120, title: '商品采购统计', align:'center', colspan: 3},
						 {width: 120, title: '商品销售统计', align:'center', colspan: 3},
                         {width: 120, title: '商品盘点统计', align:'center', colspan: 2},
						 ],[
						 {field: 'proId', width: 119, title: '商品编号', sort: true, align: "center", totalRowText: '合计:'},
						 {field: 'invTurnProName', minWidth: 200, title: '商品名称', align: "center"},
						 {field: 'invTurnInventoryNum', width: 100, title: '库存数量', align: "center", totalRow: true},
						 {field: 'invTurnManufacturer', width: 200, title: '生产厂商', align: "center"},
						 {field: 'invPurchaseNum', width: 110, title: '采购数量', sort: true, align: "center", totalRow: true},
						 {field: 'invPurchaseReturnNum', width: 110, title: '退货数量', sort: true, align: "center", totalRow: true},
						 {field: 'totalPurchaseNum', width: 110, title: '合计数量', sort: true, align: "center", totalRow: true},
						 {field: 'invTurnSalOrdNum', width: 110, title: '销售数量', sort: true, align: "center", totalRow: true},
						 {field: 'invTurnSalRetNum', width: 110, title: '退货数量', sort: true, align: "center", totalRow: true},
						 {field: 'totalSalOrdNum', width: 110, title: '合计数量', sort: true, align: "center", totalRow: true},
                         {field: 'invTurnBreakNum', width: 110, title: '报损数量', sort: true, align: "center", totalRow: true},
                         {field: 'invTurnMoreNum', width: 110, title: '报溢数量', sort: true, align: "center", totalRow: true},
					 ]],
					 limits: [10, 15, 20, 25, 50, 100],
					 limit: 10,
					 page: true
				});
				
				//变动汇总表
				table.render({
					 elem: '#changeCollectTable',
					 url: '/searchWareMonthChange?'+wareChange,
					 toolbar: '#toolbarDemo',
					 defaultToolbar: ['filter', 'exports', 'print', {
						 title: '提示',
						 layEvent: 'LAYTABLE_TIPS',
						 icon: 'layui-icon-tips'
					 }],
                     totalRow: true,
                     cols: [[
                         {field: 'proId', width: 120, title: '商品编号', sort: true, align: "center", totalRowText: '合计:'},
                         {field: 'invTurnProName', width: 370, title: '商品名称', align: "center"},
                         {field: 'invUnitName', width: 100, title: '单位', align: "center"},
                         /*{field: 'invTurnModel', title: '规格', width: 120, align: "center"},*/
                         {field: 'invTurnManufacturer', minWidth: 221, title: '生产厂商', align: "center"},
                         /*{field: 'invSupplier', width: 120, title: '供货商', align: "center"},*/
                         {field: 'lastMonthInventory', width: 120, title: '上月库存', sort: true, align: "center", totalRow: true},
                         {field: 'thisMonthPurchase', width: 120, title: '本月采购', sort: true, align: "center", totalRow: true},
                         {field: 'thisMonthSell', width: 120, title: '本月销售', sort: true, align: "center", totalRow: true},
                         {field: 'invTurnInventoryNum', width: 120, title: '本月库存', sort: true, align: "center", totalRow: true}
                     ]],
					 limits: [10, 15, 20, 25, 50, 100],
					 limit: 10,
					 page: true
				});
				
				//变动明细表
				table.render({
					 elem: '#changeDetailTable',
					 url: '/searchWareMonthChangeDesc?'+wareChange,
					 toolbar: '#toolbarDemo',
					 defaultToolbar: ['filter', 'exports', 'print', {
						 title: '提示',
						 layEvent: 'LAYTABLE_TIPS',
						 icon: 'layui-icon-tips'
					 }],
                    totalRow: true,
                    cols: [[
                        {field: 'proId', width: 110, title: '商品编号', sort: true, align: "center", totalRowText: '合计:'},
                        {field: 'invTurnProName', width: 320, title: '商品名称', align: "center"},
                        {field: 'invUnitName', width: 80, title: '单位', align: "center"},
                        /*{field: 'invTurnModel', title: '规格', width: 120, align: "center"},*/
                        {field: 'invTurnManufacturer', minWidth: 200, title: '生产厂商', sort: true, align: "center"},
                        /*{field: 'invSupplier', width: 120, title: '供货商', align: "center"},*/
                        {field: 'invTurnBatchNum', width: 120, title: '批号', align: "center"},
                        {field: 'lastMonthInventory', width: 115, title: '上月库存', sort: true, align: "center", totalRow: true},
                        {field: 'thisMonthPurchase', width: 115, title: '本月采购', sort: true, align: "center", totalRow: true},
                        {field: 'thisMonthSell', width: 115, title: '本月销售', sort: true, align: "center", totalRow: true},
                        {field: 'invTurnInventoryNum', width: 115, title: '本月库存', sort: true, align: "center", totalRow: true}
                    ]],
					 limits: [10, 15, 20, 25, 50, 100],
					 limit: 10,
					 page: true
				});


				//树形控件
                var loadIndex = layer.load(1, {
                    shade: [0.5,'#fff'] //0.1透明度的白色背景
                });
                $.ajax({
                    url:'/showProductTypeInfo',
                    success:function (data) {
                        layer.close(loadIndex);
                        var treeData = JSON.parse(data);
                        treeData[0].spread = true;
                        tree.render({
                            elem: '#treeContext',
                            data: treeData,
                            click:function (obj) {
                                var typeName = obj.data.id;
                                if('0000' == typeName){
                                    typeName = '';
                                }
                                $("input[name='inveDescType']").val(typeName);
                                $("#comTypeTree").val(obj.data.title);
                            }
                        });
                    }
                });
                //单击显示树形控件
                $("#comTypeTree").click(function () {
                    $("#treeControl").slideDown("fast");
				});

                //树形控件清空按钮
                $("#treeContext+div button:first-child").click(function () {
                    $("#comTypeTree").val("所有类别");
                    $("input[name='inveDescType']").val("");
				});

                //树形控件退出按钮
                $("#treeContext+div button:last-child").click(function () {
                    $("#treeControl").slideUp("fast");
                });
			});
		</script>
	</body>
</html>
